/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:张熳
 * Date:2025-08-09
 * Time:20:05
 */
//逻辑控制

import java.util.Scanner; //输入需要导入 util包
import java.util.Random;

public class Test {
    public static void main(String[] args) {
        //猜数字游戏
        Scanner scanner = new Scanner(System.in);
        //生成随机数
        Random random = new Random();
        int randNum = random.nextInt(100);//[0,100)
        //System.out.println(randNum);
        while (true){
            System.out.print("请输入你要猜的数字:");
            int num = scanner.nextInt();
            if(num < randNum){
                System.out.println("小了");
            } else if (num == randNum) {
                System.out.println("猜对了");
                break;
            }else {
                System.out.println("大了");
            }
        }
    }
    public static void main14(String[] args) {
        Scanner scan = new Scanner(System.in);
        System.out.print("请输入字符串:");
        String str = scan.next();
        System.out.println(str);

        /*System.out.print("请输入字符串:");
        String str1 = scan.nextLine();
        System.out.println(str1);*/
    }
    public static void main13(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.print("请输入浮点数:");
        float f = scanner.nextFloat();
        System.out.println(f);//12.5 回车\n

        scanner.nextLine();//吸收掉\n

        System.out.print("请输入字符串:");
        String str = scanner.nextLine();
        System.out.println(str);
    }
    public static void main12(String[] args) {
        //从键盘输入
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();

        int sum = 0;
        for (int j = 1; j <= n; j++) {
            int ret = 1;
            for (int i = 1; i <= j; i++) {
                ret *= i;
            }
            sum += ret;
        }
        System.out.println(sum);
    }
    public static void main11(String[] args) {
        //do while循环
        //打印1~10
        int num = 1;
        do{
            System.out.print(num+" ");
            num++;
        }while (num <= 10);
    }
    public static void main10(String[] args) {
        //求每个数字的阶乘相加的结果
        int sum = 0;
        for (int j = 1; j <= 5; j++) {
            int ret = 1;
            for (int i = 1; i <= j; i++) {
                ret *= i;
            }
            sum += ret;
        }
        System.out.println(sum);//153
    }
    public static void main9(String[] args) {
        //打印阶乘
        int ret = 1;
        for (int i = 1; i <= 5 ; i++) {
            ret *= i;
        }
        System.out.println(ret);//120
    }
    public static void main8(String[] args) {
        //for循环
        //打印1~10
        for (int i = 1; i <= 10; i++) {
            System.out.print(i+" ");
        }
    }
    public static void main7(String[] args) {
        //求出1~100之间所有既能被3整除，也能被5整除的数字，要使用break或者continue
        int i = 1;
        while (i <= 100){
            if(i % 15 != 0){
                i++;
                continue;
            }
            System.out.println(i);
            i++;
        }
    }
    public static void main6(String[] args) {
        //break - 某次循环下，执行完就不需要执行剩下的循环了
        //continue - 某次循环下，当次循环不需要执行了，直接执行下次循环
        int i = 1;
        while (i <= 7){
            if(i == 3){
                i++;
                continue;
            }
            System.out.println(i);
            i++;
        }
    }
    public static void main5(String[] args) {
        //求每个数的阶乘相加的结果
        int j = 1;
        int sum = 0;
        while (j <= 5){
            int i = 1;
            int ret = 1;
            while(i <= j){
                ret *= i;
                i++;
            }
            j++;
            sum += ret;
        }
        System.out.println(sum);//153
    }
    public static void main4(String[] args) {
        //打印阶乘
        int i = 1;
        int ret = 1;
        while (i <= 5){
            ret *= i;
            i++;
        }
        System.out.println(ret);
    }
    public static void main3(String[] args) {
        //循环结构 - while循环
        //打印1~10
        int i = 1;
        while (i <= 10){
            System.out.print(i+" ");
            i++;
        }

        //死循环
        /*while (true){
            System.out.println("死循环");
        }*/
    }
    public static void main2(String[] args) {
        //switch语句
        /*int a = 1;
        switch(a){
            case 1:
                System.out.println(1);
                break;
            case 2:
                System.out.println(2);
                break;
            default:
                System.out.println("haha");
                break;
        }*/

        /*boolean flg = true; error
        switch(flg){
            case true:
                System.out.println(1);
                break;
            case false:
                System.out.println(2);
                break;
            default:
                System.out.println("haha");
                break;
        }*/

        String flg = "hello";
        switch(flg){
            case "true":
                System.out.println(1);
                break;
            case "false":
                System.out.println(2);
                break;
            default:
                System.out.println("haha");
                break;
        }

        //switch不能表达复杂的条件
        /*int a = 10;
        switch(a > 10){

        }*/
    }
    public static void main1(String[] args) {
        //分支结构 - if语句
        /*int x = 10;
        if(x == 10){
            System.out.println("x == 20");
        }*/

        int num = 10;
        if(num % 2 == 0){
            System.out.println("偶数");
        }else{
            System.out.println("奇数");
        }
    }
}
//
